/*
 * PurchaseInfo.java
 *
 * $Id: PurchaseInfo.java,v 1.1 2008-03-18 12:58:46 mario Exp $
 */
package org.ceteca.explica.core.traceability.tree;

/**
 * ValueObject with the data of a Purchase item.
 * <br/>
 * Responsibilities:
 * <ul>
 *  <li>Store the purchase data.</li>
 * </ul>
 * <br/>
 * @author Mario García García <mario@imagos.es>
 * Copyright (c) 2007 Fundación Centro Tecnolóxico da Carne
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <br/>
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * <br/>
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
public class PurchaseInfo {
	/** Purchase confirmation code */
	private String codPurchaseConfirmation;
	/** Purchase supplier */
	private String codSupplier;

	/**
	 * Default PurchaseInfo constructor
	 */
	public PurchaseInfo() {
		this.setCodPurchaseConfirmation(null);
		this.setCodSupplier(null);
	}
	
	/**
	 * PurchaseInfo constructor that initializes the purchase values.
	 * @param codPurchaseConfirmation String, purchase confirmation code. 
	 * @param codSupplier String, purchase supplier code.
	 */
	public PurchaseInfo(String codPurchaseConfirmation, String codSupplier) {
		this.setCodPurchaseConfirmation(codPurchaseConfirmation);
		this.setCodSupplier(codSupplier);
	}
	/**
	 * Gets the purchase confirmation code.
	 * @return String, purchase confirmation code.
	 */
	public String getCodPurchaseConfirmation() {
		return codPurchaseConfirmation;
	}
	/**
	 * Sets up the purchase confirmation code.
	 * @param codPurchaseConfirmation String, a purchase confirmation code.
	 */
	public void setCodPurchaseConfirmation(String codPurchaseConfirmation) {
		this.codPurchaseConfirmation = codPurchaseConfirmation;
	}
	
	/**
	 * Gets the purchase supplier code.
	 * @return String, purchase supplier code.
	 */
	public String getCodSupplier() {
		return codSupplier;
	}
	/**
	 * Sets up the purchase supplier code.
	 * @param codSupplier String, a supplier code.
	 */
	public void setCodSupplier(String codSupplier) {
		this.codSupplier = codSupplier;
	}
	
	/**
	 * Converts the purchase info to a formatted String.
	 * @return String, formatted String with the purchase's data.
	 */
	public String toString() {
		StringBuffer result = new StringBuffer();
		result.append(this.codPurchaseConfirmation);
		result.append("   (");
		result.append(this.codSupplier);
		result.append(")");
		
		return result.toString();
	}
	
	/**
	 * Updates the purchase data.
	 * @param info PurchaseInfo, new purchase data.
	 */
	public void update(PurchaseInfo info) {
		this.setCodPurchaseConfirmation(info.getCodPurchaseConfirmation());
		this.setCodSupplier(info.getCodSupplier());
	}
	
	/**
	 * Returns tag Id assigned to CVS source file.
	 */
	public static String getRevision() {
		return "$Id: PurchaseInfo.java,v 1.1 2008-03-18 12:58:46 mario Exp $";
	}
}
